package customview.com.imageselectordemo;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import java.util.ArrayList;
import java.util.List;

import me.nereo.multi_image_selector.MultiImageSelector;
import me.nereo.multi_image_selector.MultiImageSelectorActivity;

public class Ac_MultiImageSelector extends AppCompatActivity {

    private static final int REQUEST_IMAGE = 102;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_multi_image_selector);

    }

    public void test(View view)
    {
        switch (view.getId())
        {
            case R.id.start:

                MultiImageSelector.create()
                        .showCamera(true) // 是否显示相机. 默认为显示
                  .count(9) // 最大选择图片数量, 默认为9. 只有在选择模式为多选时有效
                   //.single() // 单选模式
                    .multi() // 多选模式, 默认模式;
                    .origin(new ArrayList<String>()) // 默认已选择图片. 只有在选择模式为多选时有效
                    .start(this, REQUEST_IMAGE);

            break;


        }

    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(requestCode == REQUEST_IMAGE){
            if(resultCode == RESULT_OK){
                // 获取返回的图片列表
                List<String> path = data.getStringArrayListExtra(MultiImageSelectorActivity.EXTRA_RESULT);
                // 处理你自己的逻辑 ....
                 for (String s:path)
                 {
                     Log.d("路径", "onActivityResult: " +s);
                 }

            }
        }
    }

}
